<template>
    <el-container>
      <el-header style="height: 130px">
          <div class="title"><span>行为决策实验平台</span></div>
          <headT></headT>
      </el-header>

      <el-main>
        <timeT></timeT>
         <kuangjia></kuangjia>
          <div class="info">
              <div class="now"><span>您当前的个人资产组合市值为：<span class="num">{{roundAssets}}点</span></span></div>
              <div class="detail">
                  <div class="now"><span>本轮收益:<span class="num">{{roundEarnings}}点</span></span></div>
                  <div class="now"><span>当前累计收益:<span class="num">{{roundAssets - chushi}}点</span></span></div>
              </div>
              <el-button class="btn" @click="toNext">确认</el-button>
          </div>
      </el-main>
      <footerT></footerT>
  </el-container>
  </template>


<script>
import {earnings} from "@/api/usingTime";
import kuangjia from '@/components/kuangjia.vue'
import timeT from '@/components/time.vue'
import footerT from '@/components/footer.vue'
import headT from '@/components/headT.vue'
import {listUserEarningsSelective} from "@/api/userEarnings";
import {selectAllByExperimentId} from "@/api/Initial";
export default{
  data(){
    return{
      queryParams: {
        id: 0,
        stageId: 0,
        roundId: 0,
        userId: 0,
        roundEarnings: 0,
        roundAssets: 0,
      },
      timeEarnings: {
        stage_id: 0,
        round_id: 0,
        user_id: 0,
      },
      roundAssets: 0,
      roundEarnings: 0,
      chushi: 1000,
    }
  },
  mounted() {
    this.huoqu()
  },
  components:{
    kuangjia,
    timeT,
    footerT,
    headT
  },
  methods:{

    huoqu(){
      this.queryParams.stageId = this.$cookies.get('stageId') == null ? 1 : parseInt(this.$cookies.get('stageId'))
      this.queryParams.roundId = this.$cookies.get('roundId') == null ? 1 : parseInt(this.$cookies.get('roundId'))
      this.queryParams.userId = parseInt( this.$cookies.get('userId') )
      listUserEarningsSelective(this.queryParams).then(res => {
        console.log(res)
        this.roundAssets = res.data.data.EarningsSelective.roundAssets
        this.roundEarnings = res.data.data.EarningsSelective.roundEarnings
      })
      selectAllByExperimentId(parseInt(this.$cookies.get('sites'))).then(res => {
        this.chushi = parseInt( res.data.data.all.assetInitial )
        // console.log(res.data.data.all.assetInitial)
      })
    },

    toNext(){
      this.timeEarnings.stage_id = this.$cookies.get('stageId') == null ? 1 : parseInt(this.$cookies.get('stageId'))
      this.timeEarnings.round_id = this.$cookies.get('roundId') == null ? 1 : parseInt(this.$cookies.get('roundId'))
      this.timeEarnings.user_id = parseInt( this.$cookies.get('userId') )
      earnings(this.timeEarnings).then(res => {
        console.log(res)
      })
      this.$router.push('/choice')
    }
  }

}

</script>

  <style scoped>

.el-header{
      padding: 0;
  }

  .title{
      height: 100px;
      color: aliceblue;
      text-align: center;
      line-height: 100px;
      font-size: 50px;
      font-weight: 800;
      background-image: linear-gradient(
        DodgerBlue,
        DeepSkyBlue
      );
    }

    .round{
      height: 29px;
      box-sizing: content-box;
      border-bottom: 2px solid #dcdcdc;
      padding-left: 150px;
      line-height: 29px;
      font-size: 10px;
      font-weight: 600;
    }

    .el-main {
      /* background-color: #E9EEF3; */
      background-color: aliceblue;
      color: #333;
      text-align: center;
      height: 560px;
    }

    .info{
      width:800px ;
      height: 250px;
      margin: 0 auto;
    }

    .now{
      font-size: 20px;
      font-weight: 500;
      height: 70px;
      vertical-align: middle;
    }

    .detail{
      display: flex;
      justify-content: space-between;
    }

    .num{
      color: #0099FC;
      font-size: 30px;
      font-weight: 700;
    }

    .btn{
      margin-top: 70px;
      color: aliceblue;
      font-size: 20px;
      font-weight: 500;
      width: 200px;
      height: 50px;
      background-color: #0071fc;
      border: none;
      border-radius: 10px;
    }

    .btn:hover{
      background-color: LightSkyBlue;
      color: #333;
    }

  </style>
